home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Mail / pine3.92 / pine / newmail.c < prev    next >
C/C++ Source or Header  |  1996-03-14  |  20KB  |  619 lines

  1. #if !defined(lint) && !defined(DOS)
  2. static char rcsid[] = "$Id: newmail.c,v 4.64 1996/03/15 07:13:42 hubert Exp $";
  3. #endif
  4. /*----------------------------------------------------------------------
  5.  
  6.             T H E    P I N E    M A I L   S Y S T E M
  7.  
  8.    Laurence Lundblade and Mike Seibel
  9.    Networks and Distributed Computing
  10.    Computing and Communications
  11.    University of Washington
  12.    Administration Builiding, AG-44
  13.    Seattle, Washington, 98195, USA
  14.    Internet: lgl@CAC.Washington.EDU
  15.              mikes@CAC.Washington.EDU
  16.  
  17.    Please address all bugs and comments to "pine-bugs@cac.washington.edu"
  18.  
  19.  
  20.    Pine and Pico are registered trademarks of the University of Washington.
  21.    No commercial use of these trademarks may be made without prior written
  22.    permission of the University of Washington.
  23.  
  24.    Pine, Pico, and Pilot software and its included text are Copyright
  25.    1989-1996 by the University of Washington.
  26.  
  27.    The full text of our legal notices is contained in the file called
  28.    CPYRIGHT, included with this distribution.
  29.  
  30.  
  31.    Pine is in part based on The Elm Mail System:
  32.     ***********************************************************************
  33.     *  The Elm Mail System  -  Revision: 2.13                             *
  34.     *                                                                     *
  35.     *             Copyright (c) 1986, 1987 Dave Taylor              *
  36.     *             Copyright (c) 1988, 1989 USENET Community Trust   *
  37.     ***********************************************************************
  38.  
  39.  
  40.   ----------------------------------------------------------------------*/
  41.  
  42. /*======================================================================
  43.      newmail.c
  44.  
  45.    Check for new mail and queue up notification
  46.  
  47.  ====*/
  48.  
  49. #include "headers.h"
  50.  
  51.  
  52. /*
  53.  * Internal prototypes
  54.  */
  55. void new_mail_mess PROTO((MAILSTREAM *, char *, long, long, int));
  56. void fixup_flags PROTO((MAILSTREAM *, MSGNO_S *, long));
  57.  
  58.  
  59. static long mailbox_mail_since_command = 0L,
  60.         inbox_mail_since_command   = 0L;
  61.  
  62. /*----------------------------------------------------------------------
  63.      new_mail() - check for new mail in the inbox
  64.  
  65.   Input:  force       -- flag indicating we should check for new mail no matter
  66.           time_for_check_point -- 0: GoodTime, 1: BadTime, 2: VeryBadTime
  67.       do_status_message -- flag telling us to q a new mail status message
  68.  
  69.   Result: returns -1 if there was no new mail. Otherwise returns the
  70.           sorted message number of the smallest message number that
  71.           was changed. That is the screen needs to be repainted from
  72.           that message down.
  73.  
  74.   Limit frequency of checks because checks use some resources. That is
  75.   they generate an IMAP packet or require locking the local mailbox.
  76.   (Acutally the lock isn't required, a stat will do, but the current
  77.    c-client mail code locks before it stats.)
  78.  
  79.   Returns >= 0 only if there is a change in the given mail stream. Otherwise
  80.   this returns -1.  On return the message counts in the pine
  81.   structure are updated to reflect the current number of messages including
  82.   any new mail and any expunging.
  83.  
  84.  --- */
  85. long
  86. new_mail(force, time_for_check_point, do_status_msg)
  87.     int force, time_for_check_point, do_status_msg;
  88. {
  89.     static time_t last_check = 0;
  90.     static time_t last_check_point_call = 0;
  91.     time_t        now;
  92.     long          rv;
  93.     MAILSTREAM   *stream;
  94.     register struct pine *pine_state;
  95.     int           checknow = 0;
  96.     int           act_on_deferred = 0;
  97.  
  98.     dprint(9, (debugfile, "new mail called (%d %d %d)\n",
  99.                force, time_for_check_point, do_status_msg));
  100.     pine_state = ps_global;  /*  this gets called out of the composer which
  101.                               *  doesn't know about pine_state
  102.                               */
  103.     now = time(0);
  104.     if(pine_state->sort_is_deferred){
  105.     if(pine_state->sort_is_deferred > 1)
  106.       act_on_deferred++;
  107.  
  108.     pine_state->sort_is_deferred++; /* if not this time, act next time */
  109.     }
  110.  
  111.     /*
  112.      * only check every 15 seconds, unless we're compelled to
  113.      */
  114.     if(!(stream = pine_state->mail_stream)
  115.        || (timeout == 0 && !force)
  116.        || (now-last_check_point_call <= 15 && time_for_check_point != 0
  117.        && !pine_state->mail_box_changed && !force
  118.        && !act_on_deferred))
  119.       return(-1);
  120.     else if(force || now-last_check >= timeout-2){ /* 2: check each timeout */
  121.     checknow++;
  122.         last_check = now;
  123.     }
  124.  
  125.     last_check_point_call = now;
  126.  
  127.     if(!check_point(time_for_check_point == 0 ? GoodTime:
  128.           time_for_check_point == 1 ? BadTime : VeryBadTime) && checknow){
  129.     if(F_ON(F_SHOW_DELAY_CUE, ps_global) && !ps_global->in_init_seq){
  130.         StartInverse();
  131.         PutLine0(0, 1, "*");    /* Show something to indicate delay */
  132.         MoveCursor(ps_global->ttyo->screen_rows -FOOTER_ROWS(ps_global),0);
  133.         fflush(stdout);
  134.     }
  135.  
  136. #ifdef    DEBUG
  137.     now = time(0);
  138.     dprint(7, (debugfile, "Mail_Ping(mail_stream): %s\n", ctime(&now)));
  139. #endif
  140.         /*-- Ping the mailstream to check for new mail --*/
  141.         dprint(6, (debugfile, "New mail checked \n"));
  142.     if((char *)mail_ping(stream) == NULL)
  143.       pine_state->dead_stream = 1;
  144.  
  145. #ifdef    DEBUG
  146.     now = time(0);
  147.     dprint(7, (debugfile, "Ping complete: %s\n", ctime(&now)));
  148. #endif
  149.     if(F_ON(F_SHOW_DELAY_CUE, ps_global) && !ps_global->in_init_seq){
  150.         PutLine0(0, 1, " ");
  151.         EndInverse();
  152.         fflush(stdout);
  153.     }
  154.     }
  155.  
  156.     if(checknow && pine_state->inbox_stream 
  157.        && stream != pine_state->inbox_stream){
  158.     if(F_ON(F_SHOW_DELAY_CUE, ps_global)){
  159.         StartInverse();
  160.         PutLine0(0, 1, "*");     /* Show something to indicate delay */
  161.         MoveCursor(ps_global->ttyo->screen_rows -FOOTER_ROWS(ps_global),0);
  162.         fflush(stdout);
  163.     }
  164.  
  165. #ifdef    DEBUG
  166.     now = time(0);
  167.     dprint(7, (debugfile, "Mail_Ping(inbox_stream): %s\n", ctime(&now)));
  168. #endif
  169.     if((char *)mail_ping(pine_state->inbox_stream) == NULL)
  170.       pine_state->dead_inbox = 1;
  171.  
  172. #ifdef    DEBUG
  173.     now = time(0);
  174.     dprint(7, (debugfile, "Ping complete: %s\n", ctime(&now)));
  175. #endif
  176.     if(F_ON(F_SHOW_DELAY_CUE, ps_global)){
  177.         PutLine0(0, 1, " ");
  178.         EndInverse();
  179.         fflush(stdout);
  180.     }
  181.     }
  182.  
  183.  
  184.     /*-------------------------------------------------------------
  185.        Mail box state changed, could be additions or deletions.
  186.       -------------------------------------------------------------*/
  187.     if(pine_state->mail_box_changed || act_on_deferred) {
  188.         dprint(7, (debugfile,
  189.         "New mail, %s,  new_mail_count:%d  expunge count:%d,  max_msgno:%d\n",
  190.                    pine_state->mail_stream == pine_state->inbox_stream ?
  191.                       "inbox" : "other",
  192.                    pine_state->new_mail_count,
  193.                    pine_state->expunge_count,
  194.                    mn_get_total(pine_state->msgmap)));
  195.  
  196.     if(pine_state->mail_box_changed)
  197.       fixup_flags(pine_state->mail_stream, pine_state->msgmap,
  198.             pine_state->new_mail_count);
  199.  
  200.     /*
  201.      * Lastly, worry about sorting if we got something new, otherwise
  202.      * it was taken care of inside mm_expunge...
  203.      */
  204.     if(pine_state->new_mail_count > 0L || act_on_deferred){
  205.         /* if zoomed, defer the sort */
  206.         if(any_lflagged(pine_state->msgmap, MN_HIDE))
  207.           pine_state->sort_is_deferred = 1; /* defer (or leave deferred) */
  208.         else{
  209.         /*
  210.          * When new mail arrived, mm_exists cleared the cache.
  211.          * However, if we deferred the sort at that time and are
  212.          * sorting now, we need to clear the cache again.
  213.          */
  214.         if(pine_state->sort_is_deferred)
  215.           clear_index_cache();
  216.  
  217.         sort_current_folder(1, mn_get_sort(pine_state->msgmap),
  218.                     mn_get_revsort(pine_state->msgmap));
  219.         }
  220.     }
  221.  
  222.         if(ps_global->new_mail_count > 0 || mailbox_mail_since_command) {
  223.             mailbox_mail_since_command += ps_global->new_mail_count;
  224.  
  225.             new_mail_mess(pine_state->mail_stream,
  226.                       pine_state->mail_stream == pine_state->inbox_stream ?
  227.                       NULL :  pine_state->cur_folder,
  228.                       mailbox_mail_since_command,
  229.               mn_get_total(pine_state->msgmap),
  230.               do_status_msg);
  231.         }
  232.     }
  233.  
  234.     if(pine_state->inbox_changed
  235.        && pine_state->inbox_stream != pine_state->mail_stream) {
  236.         /*--  New mail for the inbox, queue up the notification           --*/
  237.         /*-- If this happens then inbox is not current stream that's open --*/
  238.         dprint(7, (debugfile,
  239.          "New mail, inbox, new_mail_count:%ld expunge: %ld,  max_msgno %ld\n",
  240.                    pine_state->inbox_new_mail_count,
  241.                    pine_state->inbox_expunge_count,
  242.                    mn_get_total(pine_state->inbox_msgmap)));
  243.  
  244.     fixup_flags(pine_state->inbox_stream, pine_state->inbox_msgmap,
  245.             pine_state->inbox_new_mail_count);
  246.  
  247.         if(pine_state->inbox_new_mail_count > 0 || inbox_mail_since_command) {
  248.             inbox_mail_since_command       += ps_global->inbox_new_mail_count;
  249.             ps_global->inbox_new_mail_count = 0;
  250.             new_mail_mess(pine_state->inbox_stream,NULL,
  251.                           inbox_mail_since_command,
  252.               mn_get_total(pine_state->inbox_msgmap),
  253.               do_status_msg);
  254.         }
  255.     }
  256.  
  257.     rv = mailbox_mail_since_command
  258.      + inbox_mail_since_command + pine_state->expunge_count;
  259.     if(do_status_msg){
  260.     pine_state->inbox_changed    = 0;
  261.     pine_state->mail_box_changed = 0;
  262.     }
  263.  
  264.     ps_global->new_mail_count    = 0L;
  265.  
  266.     if(pine_state->shown_newmail
  267.        && !(mailbox_mail_since_command || inbox_mail_since_command)){
  268.     icon_text(NULL);
  269.     pine_state->shown_newmail = 0;
  270.     }
  271.  
  272.     dprint(6, (debugfile, "******** new mail returning %ld  ********\n", 
  273.            rv ? rv : -1));
  274.     return(rv ? rv : -1);
  275. }
  276.  
  277.  
  278. /*----------------------------------------------------------------------
  279.      Format and queue a "new mail" message
  280.  
  281.   Args: stream     -- mailstream on which a mail has arrived
  282.         folder     -- Name of folder, NULL if inbox
  283.         number     -- number of new messages since last command
  284.         max_num    -- The number of messages now on stream
  285.  
  286.  Not too much worry here about the length of the message because the
  287. status_message code will fit what it can on the screen and truncation on
  288. the right is about what we want which is what will happen.
  289.   ----*/
  290. void
  291. new_mail_mess(stream, folder, number, max_num, do_status_msg)
  292.      MAILSTREAM *stream;
  293.      long        number, max_num;
  294.      char       *folder;
  295.      int         do_status_msg;
  296.  
  297. {
  298.     ENVELOPE    *e;
  299.     char     subject[200], from[2*MAX_SCREEN_COLS], intro[50 + MAXFOLDER];
  300.     static char *carray[] = { "regarding",
  301.                 "concerning",
  302.                 "about",
  303.                 "as to",
  304.                 "as regards",
  305.                 "as respects",
  306.                 "in re",
  307.                 "re",
  308.                 "respecting",
  309.                 "in point of",
  310.                 "with regard to",
  311.                 "subject:"
  312.     };
  313.  
  314. #ifdef _WINDOWS
  315.     mswin_newmailicon ();
  316. #endif
  317.  
  318.     if(!do_status_msg)
  319.       return;
  320.  
  321.     if(!folder) {
  322.         if(number > 1)
  323.           sprintf(intro, "%ld new messages!", number);
  324.         else
  325.           strcpy(intro, "New mail!");
  326.     }
  327.     else {
  328.         if(number > 1)
  329.           sprintf(intro,"%ld messages saved to folder \"%s\"", number, folder);
  330.         else
  331.           sprintf(intro, "Mail saved to folder \"%s\"", folder);
  332.     }
  333.  
  334.     if((e = mail_fetchstructure(stream, max_num, NULL)) && e->from)
  335.       sprintf(from, " %srom %.*s%s%s",
  336.           (number > 1L) ? "Most recent f" : "F",
  337.           ps_global->ttyo->screen_cols,
  338.           (e->from->personal)
  339.         ? (char *) rfc1522_decode((unsigned char *) tmp_20k_buf,
  340.                       e->from->personal, NULL)
  341.         : e->from->mailbox,
  342.           (e->from->personal) ? "" : "@",
  343.           (e->from->personal) ? "" : e->from->host);
  344.     else
  345.       from[0] = '\0';
  346.  
  347.     if(number <= 1L) {
  348.         if(e && e->subject)
  349.       sprintf(subject, " %s %.150s", carray[(unsigned)random()%12],
  350.           (char *) rfc1522_decode((unsigned char *) tmp_20k_buf,
  351.                       e->subject, NULL));
  352.     else
  353.       strcpy(subject, " with no subject");
  354.  
  355.         if(!from[0])
  356.           subject[1] = toupper(subject[1]);
  357.  
  358.         q_status_message3(SM_ASYNC | SM_DING, 0, 60,
  359.               "%s%s%s", intro, from, subject);
  360.     }
  361.     else
  362.       q_status_message2(SM_ASYNC | SM_DING, 0, 60, "%s%s", intro, from);
  363.  
  364.     sprintf(tmp_20k_buf, "%s%s", intro, from);
  365.     icon_text(tmp_20k_buf);
  366.     ps_global->shown_newmail = 1;
  367. }
  368.  
  369.  
  370.  
  371. /*----------------------------------------------------------------------
  372.   Straighten out any local flag problems here.  We can't take care of
  373.   them in the mm_exists or mm_expunged callbacks since the flags
  374.   themselves are in an MESSAGECACHE and we're not allowed to reenter
  375.   c-client from a callback...
  376.  
  377.  Args: stream -- mail stream to operate on
  378.        msgmap -- messages in that stream to fix up
  379.        new_msgs -- number of new messages
  380.  
  381.  Result: returns with local flags as they should be
  382.  
  383.   ----*/
  384. void
  385. fixup_flags(stream, msgmap, new_msgs)
  386.     MAILSTREAM *stream;
  387.     MSGNO_S    *msgmap;
  388.     long    new_msgs;
  389. {
  390.     long i;
  391.  
  392.     if(new_msgs > 0L && any_lflagged(msgmap, MN_HIDE)){
  393.     i = mn_get_total(msgmap) - new_msgs + 1L;
  394.     while(i > 0L && i <= mn_get_total(msgmap))
  395.       set_lflag(stream, msgmap, i++, MN_HIDE, 1);
  396.     }
  397.  
  398.     /*
  399.      * Also, worry about the case where expunged away all of the 
  400.      * zoomed messages.  Unhide everything in that case...
  401.      */
  402.     if(mn_get_total(msgmap) > 0L){
  403.     if(any_lflagged(msgmap, MN_HIDE) >= mn_get_total(msgmap)){
  404.         for(i = 1L; i <= mn_get_total(msgmap); i++)
  405.           set_lflag(stream, msgmap, i, MN_HIDE, 0);
  406.  
  407.         mn_set_cur(msgmap, mn_get_total(msgmap));
  408.     }
  409.     else if(any_lflagged(msgmap, MN_HIDE)){
  410.         /*
  411.          * if we got here, there are some hidden messages and
  412.          * some not.  Make sure the current message is one
  413.          * that's not...
  414.          */
  415.         for(i = mn_get_cur(msgmap); i <= mn_get_total(msgmap); i++)
  416.           if(!get_lflag(stream, msgmap, i, MN_HIDE)){
  417.           mn_set_cur(msgmap, i);
  418.           break;
  419.           }
  420.  
  421.         for(i = mn_get_cur(msgmap); i > 0L; i--)
  422.           if(!get_lflag(stream, msgmap, i, MN_HIDE)){
  423.           mn_set_cur(msgmap, i);
  424.           break;
  425.           }
  426.     }
  427.     }
  428. }
  429.  
  430.  
  431.  
  432. /*----------------------------------------------------------------------
  433.     Force write of the main file so user doesn't lose too much when
  434.  something bad happens. The only thing that can get lost is flags, such 
  435.  as when new mail arrives, is read, deleted or answered.
  436.  
  437.  Args: timing      -- indicates if it's a good time for to do a checkpoint
  438.  
  439.   Result: returns 1 if checkpoint was written, 
  440.                   0 if not.
  441.  
  442. NOTE: mail_check will also notice new mail arrival, so it's imperative that
  443. code exist after this function is called that can deal with updating the 
  444. various pieces of pine's state associated with the message count and such.
  445.  
  446. Only need to checkpoint current stream because there are no changes going
  447. on with other streams when we're not manipulating them.
  448.   ----*/
  449. static int check_count        = 0;  /* number of changes since last chk_pt */
  450. static long first_status_change = 0;  /* time of 1st change since last chk_pt*/
  451. static long last_status_change    = 0;  /* time of last change                 */
  452. static long check_count_ave    = 10 * 10;
  453.  
  454. check_point(timing)
  455.      CheckPointTime timing;
  456. {
  457.     int     freq, tm;
  458.     long    adj_cca;
  459.     long    tmp;
  460. #ifdef    DEBUG
  461.     time_t  now;
  462. #endif
  463.  
  464.     dprint(9, (debugfile, "check_point(%s)\n", 
  465.                timing == GoodTime ? "GoodTime" :
  466.                timing == BadTime  ? "BadTime" :
  467.                timing == VeryBadTime  ? "VeryBadTime" : "DoItNow"));
  468.  
  469.     if(!ps_global->mail_stream || ps_global->mail_stream->rdonly ||
  470.                                  check_count == 0)
  471.      return(0);
  472.  
  473.     freq = CHECK_POINT_FREQ * (timing==GoodTime ? 1 : timing==BadTime ? 3 : 4);
  474.     tm   = CHECK_POINT_TIME * (timing==GoodTime ? 1 : timing==BadTime ? 2 : 3);
  475.  
  476.     dprint(9, (debugfile, "freq: %d  count: %d\n", freq, check_count));
  477.     dprint(9, (debugfile, "tm: %d  elapsed: %d\n", tm,
  478.                time(0) - first_status_change));
  479.  
  480.     if(!last_status_change)
  481.         last_status_change = time(0);
  482.  
  483.     tmp = 10*(time(0)-last_status_change);
  484.     adj_cca = (tmp > check_count_ave) ?
  485.       min((check_count_ave + tmp)/2, 2*check_count_ave) : check_count_ave;
  486.  
  487.     dprint(9, (debugfile, "freq %d tm %d changes %d since_1st_change %d\n",
  488.            freq, tm, check_count, time(0)-first_status_change));
  489.     dprint(9, (debugfile, "since_status_chg %d chk_cnt_ave %d (tenths)\n",
  490.            time(0)-last_status_change, check_count_ave));
  491.     dprint(9, (debugfile, "adj_chk_cnt_ave %d (tenths)\n", adj_cca));
  492.     dprint(9, (debugfile, "Check:if changes(%d)xadj_cca(%d) >= freq(%d)x200\n",
  493.            check_count, adj_cca, freq));
  494.     dprint(9, (debugfile, "      is %d >= %d ?\n",
  495.            check_count*adj_cca, 200*freq));
  496.  
  497.     /* the 200 comes from 20 seconds for an average status change time
  498.        multiplied by 10 tenths per second */
  499.     if((timing == DoItNow || (check_count * adj_cca >= freq * 200) ||
  500.        (time(0) - first_status_change >= tm))){
  501. #ifdef    DEBUG
  502.     now = time(0);
  503.     dprint(7, (debugfile,
  504.                      "Doing checkpoint: %s  Since 1st status change: %d\n",
  505.                      ctime(&now), now - first_status_change));
  506. #endif
  507.     if(F_ON(F_SHOW_DELAY_CUE, ps_global)){
  508.         StartInverse();
  509.         PutLine0(0, 0, "**");    /* Show something indicate delay*/
  510.         MoveCursor(ps_global->ttyo->screen_rows -FOOTER_ROWS(ps_global),0);
  511.         fflush(stdout);
  512.     }
  513.  
  514.         mail_check(ps_global->mail_stream);
  515.                     /* Causes mail file to be written */
  516. #ifdef    DEBUG
  517.     now = time(0);
  518.     dprint(7, (debugfile, "Checkpoint complete: %s\n", ctime(&now)));
  519. #endif
  520.         check_count = 0;
  521.         first_status_change = time(0);
  522.     if(F_ON(F_SHOW_DELAY_CUE, ps_global)){
  523.         PutLine0(0, 0, "  ");
  524.         EndInverse();
  525.         fflush(stdout);
  526.     }
  527.  
  528.         return(1);
  529.     } else {
  530.         return(0);
  531.     }
  532. }
  533.  
  534.  
  535.  
  536. /*----------------------------------------------------------------------
  537.     Call this when we need to tell the check pointing mechanism about
  538.   mailbox state changes.
  539.   ----------------------------------------------------------------------*/
  540. void
  541. check_point_change()
  542. {
  543.     if(!last_status_change)
  544.         last_status_change = time(0) - 10;  /* first change 10 seconds */
  545.  
  546.     if(!check_count++)
  547.       first_status_change = time(0);
  548.     /*
  549.      * check_count_ave is the exponentially decaying average time between
  550.      * status changes, in tenths of seconds, except never grow by more
  551.      * than double, but always at least one (unless there's a fulll moon).
  552.      */
  553.     check_count_ave = min((check_count_ave +
  554.                 max(10*(time(0)-last_status_change),2))/2, 2*check_count_ave);
  555.  
  556.     last_status_change = time(0);
  557. }
  558.  
  559.  
  560.  
  561. /*----------------------------------------------------------------------
  562.     Call this when a mail file is written to reset timer and counter
  563.   for next check_point.
  564.   ----------------------------------------------------------------------*/
  565. void
  566. reset_check_point()
  567. {
  568.     check_count = 0;
  569.     first_status_change = time(0);
  570. }
  571.  
  572.  
  573.  
  574. /*----------------------------------------------------------------------
  575.     Zero the counters that keep track of mail accumulated between
  576.    commands.
  577.  ----*/
  578. void
  579. zero_new_mail_count()
  580. {
  581.     dprint(9, (debugfile, "New_mail_count zeroed\n"));
  582.     mailbox_mail_since_command = 0L;
  583.     inbox_mail_since_command   = 0L;
  584. }
  585.  
  586.  
  587. /*----------------------------------------------------------------------
  588.      Check and see if all the stream are alive
  589.  
  590. Returns:  0 if there was no change
  591.           1 if streams have died since last call
  592.  
  593. Also outputs a message that the streams have died
  594.  ----*/
  595. streams_died()
  596. {
  597.     int rv = 0, inbox = 0;
  598.  
  599.     if(ps_global->dead_stream && !ps_global->noticed_dead_stream) {
  600.         rv = 1;
  601.         ps_global->noticed_dead_stream = 1;
  602.         if(ps_global->mail_stream == ps_global->inbox_stream)
  603.           ps_global->noticed_dead_inbox = 1;
  604.     }
  605.  
  606.     if(ps_global->dead_inbox && !ps_global->noticed_dead_inbox) {
  607.         rv = 1;
  608.         ps_global->noticed_dead_inbox = 1;
  609.         inbox = 1;
  610.     }
  611.     if(rv == 1) 
  612.       q_status_message1(SM_ORDER | SM_DING, 3, 6,
  613.                         "MAIL FOLDER \"%s\" CLOSED DUE TO ACCESS ERROR",
  614.                         pretty_fn(inbox ? ps_global->inbox_name
  615.                       : ps_global->cur_folder));
  616.     return(rv);
  617. }
  618.         
  619.